<template>
  <div class="container">
    <data-view
      propViewKey="wm_stock_process"
      propViewForm="wm/process/item-detail.vue"
      :propFlowKey="propFlowKey"
      :propShowToolBar="true"
      ref="wm_stock_process"
      @extra-button-click="handleExtraButton"
      :propIsTdesign="true"
    />
  </div>
</template>

<script>

export default {
  name: 'stock',
  data() {
    return {

    }
  },
  components: {
  },
  computed: {
  },
  methods: {
    handleExtraButton({button, data}) {
      if (button.key == 'btn_unProcess') {
        this.handleUnProcess(data)
      } else if (button.key == 'btn_unSubmit') {
        this.handleUnSubmit(data)
      }
    },
    handleUnProcess(data) { //撤销加工
      this.$ajax.post('/wm/stock_process/un_process', data).then(resp => {
        if (resp.success) {
          this.utilMessage.success(resp.msg)
          this.fetchData()
        }
      })
    },
    handleUnSubmit(data) { //撤销提交
      this.$ajax.post('/wm/stock_process/un_submit', data).then(resp => {
        if (resp.success) {
          this.utilMessage.success(resp.msg)
          this.fetchData()
        }
      })
    },
    fetchData() {
      this.$refs.wm_stock_process.fetchData()
    }
  },
  props: ['propFlowKey'],
}
</script>

<style lang="scss" scoped>
  .container {
    height: 100%;
    background-color: #fff;
  }
</style>
